package com.dingdang.sms.allinone.sender

class ResultWrapper : HashMap<String, Any?>() {

    object Key {
        const val MESSAGE = "message"
        const val STATUS = "status"
        const val DATA = "data"
    }

    private val defaultMessage = "success"
    private val defaultStatus = 0
    private val defaultData = null

    private fun with(
        message: String = defaultMessage,
        status: Int = defaultStatus,
        data: Any? = defaultData
    ): ResultWrapper {
        this[Key.MESSAGE] = message
        this[Key.STATUS] = status
        this[Key.DATA] = data
        return this
    }

    fun ok(
        message: String? = null,
        data: Any? = null
    ): ResultWrapper {
        return this.with(data = data)
    }

    fun error(message: String = "error", status: Int = 500, data: Any? = null): ResultWrapper {
        return this.with(message = message, status = status, data = data)
    }
}